/*
 * @author: Archy
 * @Date: 2022-03-11 14:07:35
 * @LastEditors: Archy
 * @LastEditTime: 2022-03-15 10:41:24
 * @FilePath: \arkgen\react\src\hooks\useCmd.ts
 * @description: 
 */
import { useTerminal } from "./useTerminal"
import { useRef } from "react"

export const useCmd = () => {
  const [terminal, ws] = useTerminal()
  const localCommand = useRef<string>('')

  return (command: string) => {
    localCommand.current = command
    terminal.write('npm run ' + localCommand.current)
    ws?.send('npm run ' + localCommand.current)
    terminal.writeln('')
  }
}